import '../../../base/base_model.dart';
import '../../../http/user_dao.dart';
import '../../../resources.dart';

/// created by hcl
/// on 2024/2/27
/// MainController
/// desc
class MineModel extends BaseModel {
  String name = '';
  String account = '';
  String phone = '';

  @override
  void initData() {
    name = GSpUtils.get(GSpUtils.nickName);
    account = GSpUtils.get(GSpUtils.tempAccount);
    phone = GSpUtils.get(GSpUtils.phone);
    if (phone.length > 8) {
      phone = phone.replaceRange(phone.length - 8, phone.length - 4, '****');
    }
    notifyListeners();
  }

  goChangePassword() {
    Nav.push(routerName: AppRoutes.changePassword);
  }

  goChangePhone() {
    Nav.push(routerName: AppRoutes.changePhone);
  }

  void goAbout() {
    Toast.showLoading();
    Future.delayed(const Duration(milliseconds: 1500), () {
      Toast.close();
      showToast('已是最新版本');
    });
  }

  void goClear() {
    Toast.showLoading(msg: '清理中...');
    Future.delayed(const Duration(milliseconds: 1500), () {
      Toast.close();
      showToast('清理完毕');
    });
  }
}
